#include "main/utils.h"
using namespace std;

class Solution {
public:
    int isPrefixOfWord(string sentence, string searchWord) {
      int start = 0, end = 0, index = 1, n = sentence.size();
      while (start < n) {
        while (end < n && sentence[end] != ' ') {
          ++end;
        }
        if (isPrefix(sentence, start, end, searchWord)) {
          return index;
        }
        ++end;
        start = end;
        ++index;
      }
      return -1;
    }

    bool isPrefix(const string &sentence, int start, int end, const string &searchWord) {
      for (int i = 0; i < searchWord.size(); ++i) {
        if (start + i >= end || sentence[start + i] != searchWord[i]) {
          return false;
        }
      }
      return true;
    }
};

int main() {
  string sentence = "i love eating burget";
  string search_word = "burg";
  Solution su;
  cout << su.isPrefixOfWord(sentence, search_word) << endl;

  return 0;
}
